{% extends 'layout.html' %}
{% load permission %}


{% block content %}
    {% add_permission request 'level_add' %}
    <!--
    <a href="{% url "level_add" %}" class="btn btn-primary">添加 <span class="glyphicon glyphicon-plus-sign"></span> </a>
    -->
    <hr>
    <div style="padding: 0 20px 0 20px">
        <table class="table table-bordered table-striped table-hover">
            <thead>
            <tr>
                <td>id</td>
                <td>title</td>
                <td>percent</td>
                <!-- 对表头的权限处理 -->
                {% if request|table_permission:"level_edit,level_delete" %}
                    <td>operation</td>
                {% endif %}
            </tr>
            </thead>
            <tbody>
            {% for foo in queryset %}
                <tr>
                    <td>{{ forloop.counter }}</td>
                    <td>{{ foo.title }}</td>
                    <td>{{ foo.percent }}%</td>
                    <!-- 对body的权限处理 -->
                    {% if request|table_permission:"level_edit,level_delete" %}
                        <td>
                            {% edit_permission request 'level_edit' foo.id %}
                            {% level_delete_permission request 'level_delete' foo.id %}
                            <!--
                            <a href="{% url 'level_edit' foo.id %}" class="btn btn-info btn-sm">编辑</a>
                            <a href="{% url 'level_delete' foo.id %}" class="btn btn-danger btn-sm">删除</a>
                            -->
                        </td>
                    {% endif %}
                </tr>
            {% endfor %}
            </tbody>
        </table>
    </div>
{% endblock %}